<template>
  <a-dropdown arrow>
    <a-avatar :size="40" :src="avatar"></a-avatar>
    <template #overlay>
      <a-menu>
        <a-menu-item>
          <span>个人中心</span>
        </a-menu-item>
        <a-menu-divider />
        <a-menu-item>
          <span @click="logout">退出登录</span>
        </a-menu-item>
      </a-menu>
    </template>
  </a-dropdown>
</template>

<script setup>
import avatar from '@/assets/me.png'
import router from '@/router'
import { useUserStore } from '@/stores'
import { message } from 'ant-design-vue'
const userStore = useUserStore()
const logout = () => {
  userStore
    .LogOut(userStore.userInfo.id)
    .then((res) => {
      router.push('/login')
      message.success('退出成功')
    })
    .catch((err) => {
      message.error('退出失败')
    })
}
</script>

<style>
</style>